package com.ybfenpan.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class MD5Util {
     
    public String MD5(String md5){
    	
    	String resultMD5 = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update((md5).getBytes());
            byte ad[] = md.digest();
            int i;
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < ad.length; offset++) {
                i = ad[offset];
                if (i < 0)
                    i += 256;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }
            resultMD5 = buf.toString();
            System.out.println("MD5(32) = " + resultMD5);
            // System.out.println("MD5(16) = " + buf.toString().substring(8, 24));
        } catch (NoSuchAlgorithmException e) {
            System.out.println(e);
        }
        return resultMD5;
    }
   
}